from day11_7_30.Base.Base import Base
from selenium.webdriver.common.by import By
import time
from day11_7_30.Page.Page import Page
class Page1(Page):
    search_loc=(By.XPATH,'//*[@id="searchForm"]/div[1]/input')

    def search(self):
        self.send_keys(self.search_loc,'手机')
        self.enter(self.search_loc)

    # 预期5
    yq5_loc = (By.XPATH,'/html/body/div[4]/a[2]')
    def yq5(self):
        return self.text(self.yq5_loc)

    yq6_loc = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[3]/div[1]/p')
    def yq6(self):
        return self.text(self.yq6_loc)


    goods_loc = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[3]/div[1]/em/a')
    def goods(self):
        self.click(self.goods_loc)

    # 预期3
    yq3_loc=(By.ID,'sell-price-box')
    def yq3(self):
        return self.text(self.yq3_loc)

    nums_loc=(By.ID,'store_nums')
    def nums(self):
        self.clear(self.nums_loc)
        self.send_keys(self.nums_loc,'2')

    buy_loc = (By.ID,'buy-cart')
    def buy(self):
        self.click(self.buy_loc)

    address_loc = (By.ID,'address-35')
    def address(self):
        self.click(self.address_loc)

    radio_loc = (By.XPATH,'//*[@id="theForm"]/div[3]/div[2]/div[1]/label/input')
    def radio(self):
        self.down()
        self.click(self.radio_loc)
    # 运费
    yq4_loc = (By.XPATH,'//*[@id="real-freight"]')
    def yq4(self):
        return self.text(self.yq4_loc)
    # 商品数量
    yq7_loc = (By.XPATH,'//*[@id="theForm"]/div[4]/div[1]/table/tbody/tr[2]/td[3]')
    def yq7(self):
        return self.text(self.yq7_loc)

    order_loc = (By.ID,'order-button')
    def order(self):
        self.click(self.order_loc)
    # 您的订单支付成功 /html/body/div[4]/div[3]/span
    yq8_loc = (By.XPATH,'/html/body/div[4]/div[3]/span')
    def yq8(self):
        return self.text(self.yq8_loc)
    vip_loc = (By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[3]/a')

    def vip(self):
        self.click(self.vip_loc)
    yq9_loc = (By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[2]/div[2]/ul/li[4]/span')
    def yq9(self):
        return self.text(self.yq9_loc).replace('¥ ','')




    def a3mall_search_01(self):
        self.A3mall_log_01()
    def a3mall_search_02(self):
        time.sleep(5)
        self.search()
        print(self.yq5())
        print(self.yq6())
    def a3mall_search_03(self):
        self.goods()
        print(self.yq3())
    def a3mall_search_04(self):
        self.nums()
    def a3mall_search_05(self):
        self.buy()
    def a3mall_search_06(self):
        self.address()
    def a3mall_search_07(self):
        self.radio()
        print(self.yq4())
        print(self.yq7())
    def a3mall_search_08(self):
        self.order()
        print(self.yq8())
    def a3mall_search_09(self):
        self.vip()
        print(self.yq9())





